project(
	'DFL Gamma Effects',
	'c',
	'cpp',
	version: '0.2.0',
	license: 'GPLv3',
	meson_version: '>=0.59.0',
	default_options: [
		'cpp_std=c++17',
		'c_std=c11',
		'warning_level=2',
		'werror=false',
	],
)

add_project_arguments( '-DPROJECT_VERSION=' + meson.project_version(), language : 'cpp' )
add_project_link_arguments( ['-rdynamic','-fPIC'], language:'cpp' )

if get_option('use_qt_version') == 'qt5'
	Qt = import( 'qt5' )
	QtCore    = dependency( 'qt5', modules: [ 'Core' ] )
	QtWidgets = dependency( 'qt5', modules: [ 'Widgets' ] )
	QtNetwork = dependency( 'qt5', modules: [ 'Network' ] )
	WayQt     = dependency( 'wayqt' )

	libname = 'df5gammaeffects'
	subdirname = 'DFL/DF5'

elif get_option('use_qt_version') == 'qt6'
	Qt = import( 'qt6' )
	QtCore    = dependency( 'qt6', modules: [ 'Core' ] )
	QtWidgets = dependency( 'qt6', modules: [ 'Widgets' ] )
	QtNetwork = dependency( 'qt6', modules: [ 'Network' ] )
	WayQt     = dependency( 'wayqt-qt6' )

	libname = 'df6gammaeffects'
	subdirname = 'DFL/DF6'

endif

Wayland  = dependency( 'wayland-client' )
CoreDeps = [ QtCore, QtWidgets, QtNetwork, WayQt, Wayland ]

CoreHeaders = [
	'DFGammaEffects.hpp',
]

CoreSources = [
	'GammaEffects.cpp',
	'color_math.cpp',
]

CoreMocs = Qt.compile_moc(
	headers : [ CoreHeaders ],
	dependencies: CoreDeps
)

sunset = shared_library(
	libname, [ CoreSources, CoreMocs ],
	version: meson.project_version(),
	dependencies: CoreDeps,
	install: true,
    install_dir: join_paths( get_option( 'libdir' ) )
)

install_headers( 'DFGammaEffects.hpp', subdir: subdirname )

## PkgConfig Section
pkgconfig = import( 'pkgconfig' )
pkgconfig.generate(
	sunset,
	name: libname,
	subdirs: subdirname,
	version: meson.project_version(),
	filebase: libname,
	description: 'Classes to set custom Gamma effects like color temperature',
)
